<template>
<slot :controller="controller" :store="store" :model="model">
    <AppEXPViewLayout :class="classNames" :openType="openType">
        <template #viewHeaderContentLeft v-if="!noViewCaption && model.showCaption">
            <div class="view-header__left__caption">
                <slot name="ViewCaption" :controller="controller" :store="store" :model="model">
                    <AppCaptionBar :caption="model.caption" :title="model.title" :capPSLanguageRes="model.capPSLanguageRes" :titlePSLanguageRes="model.titlePSLanguageRes" :openType="openType"></AppCaptionBar>
                </slot>
            </div>
        </template>
        <template #default>
            <AppSplit
                v-model="split"
                class="app-vc-expbar"
                mode="horizontal"
                @move-end="handleSplitChange(model, split)">
                <template #left>
                    <div class="app-vc-expbar__left">
                        <slot name="IBIZOrderUsr2CalendarExpViewcalendarexpbarCalendarExpBar" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                        <IBIZOrderUsr2CalendarExpViewcalendarexpbarCalendarExpBar
                            ref="CalendarExpBar"
                            :openView="store.openView"
                            :newView="store.newView"
                            name="calendarexpbar"
                            v-bind="model.ctrlParams.IBIZOrdercalendarexpbar"
                            :context="store.context"
                            :viewParams="store.viewParams"
                            :closeView="store.closeView"
                            :pLoadingHelper="store.loadingHelper"
                            :pViewCtx="store.viewCtx"
                            @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                            @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                            @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }">
                        </IBIZOrderUsr2CalendarExpViewcalendarexpbarCalendarExpBar>
                        </slot>
                    </div>
                </template>
                <template #right>
                    <div class="app-vc-expbar__body">
                        <component
                            v-if="store.navParam && store.navParam.navViewName"
                            openType="EMBED"
                            :is="store.navParam.navViewName"
                            :key="store.navParam.data.srfkey"
                            :context="store.navParam.navData.context"
                            :viewParams="store.navParam.navData.viewParams"
                            :pLoadingHelper="store.loadingHelper"                
                            class="view-container2"
                            @view-init="(name:string, data:any) => { handleCtrlInit(controller, name, data); }"
							@view-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data); }"
							@view-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data); }">
                        </component>
                    </div>
                </template>
            </AppSplit>
        </template>
    </AppEXPViewLayout>
</slot>
</template>
<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@DECALENDAREXPVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppEXPViewLayout } from "@components/layout/exp-view-layout";
import { AppSplit } from '@components/common/split';
import IBIZOrderUsr2CalendarExpViewcalendarexpbarCalendarExpBar from '@widgets/ibiz-order/usr-2-calendar-exp-viewcalendarexpbar-calendar-exp-bar/usr-2-calendar-exp-viewcalendarexpbar-calendar-exp-bar.vue';
import { useProps, useBasic, useAction, useController } from './ibiz-order-usr-2-calendar-exp-view-hook';
import { IEvent, CalendarExpViewActionType, ICalendarExpViewAbility, ICalendarExpViewStore, IParam } from '@/core';

// 输入参数
const props = defineProps(useProps());

//  导航分隔值
const split = ref(0.45);

// 基础数据
const { 
    model,
    getClassNames, 
    useNavParamsBind,
	useEventBind,
    handleQuickSearch,
  	handleToolbarItemClick,
    handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy,
    initSplit,
    handleSplitChange,
    handleQuickGroupValueChange
} = useBasic(props);

const emit = defineEmits<{
    (event: 'view-action', name: string, action: CalendarExpViewActionType, data: IParam[]): void;
    (event: 'view-init', name: string, data: ICalendarExpViewAbility): void;
    (event: 'view-mounted', name: string, data: IParam): void;
    (event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: ICalendarExpViewStore = controller.getStore();

onMounted(() => {
    controller.viewMounted();
    initSplit(getCurrentInstance());
})

onUnmounted(() => {
    controller.viewDestroy();
})
</script>